package jiang;

public class VolatileTest3 {
	static VolatileTest3_resource r = new VolatileTest3_resource();
	
	public static void main(String[] args) {
		Thread t1 = new Thread(new VolatileTest3_1(r));
		Thread t2 = new Thread(new VolatileTest3_2(r));
		t1.start();
		t2.start();
	}
}

class VolatileTest3_1 implements Runnable {
	VolatileTest3_resource r;
	
	public VolatileTest3_1(VolatileTest3_resource r) {
		this.r = r;
	}

	@Override
	public void run() {
		r.a = 100;
	}

}

class VolatileTest3_2 implements Runnable {
	VolatileTest3_resource r;
	
	public VolatileTest3_2(VolatileTest3_resource r) {
		this.r = r;
	}

	@Override
	public void run() {
		System.out.println(r.a);
	}

}

class VolatileTest3_resource {
	public int a = 10;
}